#include <bits/stdc++.h>
using namespace std;
int book[300001];
int main() {
  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> book[i];
  }
  sort(book + 1, book + n + 1);
  int ans = 0;
  for (int i = n; i >= 1; i = i - 3) {
    ans += book[i] + book[i - 1];
  }
  cout <<ans;
  return 0;
}